<template>
</template>

<script>
	import { InitScene } from '@/utils/index.js'
	import { userProxyData, bindUserId } from '@/network/api.js'
	export default {
		async onLoad(options){
			await this.$onLaunched
			const userId = Number(uni.getStorageSync("user_id"))
			const userStatus = Number(uni.getStorageSync("user_status"))
			const data = InitScene(options.scene)
			/* 绑定关系 */
			const pages = getCurrentPages()
			const currentPage = pages[pages.length - 1]
			const params = {
				userid: userId,
				inviter: data.inviterId,
				url: currentPage.$page.fullPath || ''
			}
			bindUserId(params)
			/* 创建代注册人扫码 或者 已注册用户扫码 */
			const res = await userProxyData({replace_id: data.replace})
			if(userId == Number(data.inviterId) || userStatus == 2 || ![0].includes(res.data.new_user_id)){
				uni.switchTab({
					url: "/pages/home/home"
				})
			}else{
				uni.redirectTo({
					url: "/operate/proxyForm/proxyForm?data=" + JSON.stringify(data)
				})
			}
		}
	}
</script>

<style>
</style>